]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
[panel] separate "active" state from hover state in PanelBaseMenuItem
authorDan Winship <danw@gnome.org>
Tue, 18 May 2010 17:23:41 +0000 (13:23 -0400)
committerDan Winship <danw@gnome.org>
Wed, 19 May 2010 17:15:46 +0000 (13:15 -0400)
When doing keyboard navigation, the active menu item may not be the
one under the mouse.

https://bugzilla.gnome.org/show_bug.cgi?id=619008

data/theme/gnome-shell.css
js/ui/panel.js

index 3367c576d1a33f33f05901d7f4db387d01bfe8a1..93cb4b3b08b05a158f3e10a913eba6e20f3c172a 100644 (file)
@@ -142,7 +142,7 @@ StTooltip {
     padding: 6px 20px;
 }
 
-.panel-menu-item:hover {
+.panel-menu-item:active {
     background-color: #4c4c4c;
 }
 
index 05c58ef258659f0542db67dff2a2d4f2cc6de4d3..9c311a5e3a3e61e5ebf44bc0771c61f900ff07b5 100644 (file)
@@ -138,11 +138,34 @@ PanelBaseMenuItem.prototype = {
                                   x_fill: true,
                                   y_fill: true,
                                   x_align: St.Align.START });
+        this.active = false;
 
         if (reactive) {
             this.actor.connect('button-release-event', Lang.bind(this, function (actor, event) {
                 this.emit('activate', event);
             }));
+            this.actor.connect('notify::hover', Lang.bind(this, this._hoverChanged));
+        }
+    },
+
+    _hoverChanged: function (actor) {
+        this.setActive(actor.hover);
+    },
+
+    activate: function (event) {
+        this.emit('activate', event);
+    },
+
+    setActive: function (active) {
+        let activeChanged = active != this.active;
+
+        if (activeChanged) {
+            this.active = active;
+            if (active)
+                this.actor.add_style_pseudo_class('active');
+            else
+                this.actor.remove_style_pseudo_class('active');
+            this.emit('active-changed', active);
         }
     }
 };